const {service} = require("../request");
const model = require("../../utils/modelUtil");

/**
 * 登录类
 */
class Login {
    constructor(user) {
        this.user = user;
    }

    /**
     * 快速登录
     * @param data 登录数据
     * @returns {Promise<unknown>}
     */
    quickLogin(data) {
        return new Promise((resolve, reject) => {
            service({
                method: 'POST',
                url: this.user.game.quickLoginUrl + '/quicklogin',
                data: model.userModel('quicklogin', data, this.user.game.isWeb, this.user.game.data),
            }).then(res => {
                const resData = res.data;
                resolve(resData.code===200?resData.MsgData:{});
            }).catch(err => {
                reject(err);
            })
        })
    }
}

module.exports = Login;